package com.three.iot.commons.enums;

import java.util.Objects;

/**
 * @author luiz
 * @Title: ResultCode
 * @ProjectName iot
 * @Description: 绑定状态类型枚举
 * @date 2019-04-03 16:00
 */
public enum BindStatusEnum {
    BIND("BIND", "已绑定"),
    UNBIND("UNBIND", "未绑定"),
    ;
    String code;
    String name;

    BindStatusEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getNameByCode(String code) {
        BindStatusEnum iotDeviceStatusEnum=matching(code);
        if(iotDeviceStatusEnum!=null){
            return iotDeviceStatusEnum.getName();
        }
        return "";
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static final BindStatusEnum matching(String code) {
        for (BindStatusEnum iotDeviceStatusEnum : BindStatusEnum.values()) {
            if (Objects.equals(iotDeviceStatusEnum.getCode(), code)) {
                return iotDeviceStatusEnum;
            }
        }
        return null;
    }
}
